var UnLazy = function(i) {
    "use strict";
    var b;
    const O = "data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1 1'%3E%3C/svg%3E"
        , v = typeof window > "u"
        , T = !v && "loading"in HTMLImageElement.prototype
        , C = !v && (!("onscroll"in window) || /(?:gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent));
    function h(e, t=document) {
        return typeof e == "string" ? [...t.querySelectorAll(e)] : e instanceof Element ? [e] : [...e]
    }
    function D(e) {
        const t = Date.now();
        return O.replace(/\s/, ` data-id='${t}-${e}' `)
    }
    function N(e, t) {
        let r;
        return function(...n) {
            r != null && clearTimeout(r),
                r = setTimeout( () => {
                        e(...n),
                            r = void 0
                    }
                    , t)
        }
    }
    function z(e='img[loading="lazy"]', {hash: t=!0, hashType: r="blurhash", placeholderSize: n=32, updateSizesOnResize: c=!1, onImageLoad: E}={}) {
        const a = new Set;
        for (const [S,s] of h(e).entries()) {
            const A = d(s, {
                updateOnResize: c
            });
            if (c && A && a.add(A),
            !s.dataset.src && !s.dataset.srcset) {
                (typeof __UNLAZY_LOGGING__ > "u" || __UNLAZY_LOGGING__) && console.error("[unlazy] Missing `data-src` or `data-srcset` attribute", s);
                continue
            }
            if (C || !T) {
                p(s),
                    l(s),
                    f(s);
                continue
            }
            if (s.src || (s.src = D(S)),
            s.complete && s.naturalWidth > 0) {
                o(s, E);
                continue
            }
            const L = () => o(s, E);
            s.addEventListener("load", L, {
                once: !0
            }),
                a.add( () => s.removeEventListener("load", L))
        }
        return () => {
            for (const S of a)
                S();
            a.clear()
        }
    }
    function w(e='img[data-sizes="auto"], source[data-sizes="auto"]') {
        for (const t of h(e))
            d(t)
    }
    function o(e, t) {
        if (_(e)) {
            p(e),
                l(e),
                f(e),
            t == null || t(e);
            return
        }
        const r = new Image
            , {srcset: n, src: c, sizes: E} = e.dataset;
        if (E === "auto") {
            const a = y(e);
            a && (r.sizes = `${a}px`)
        } else
            e.sizes && (r.sizes = e.sizes);
        n && (r.srcset = n),
        c && (r.src = c),
            r.addEventListener("load", () => {
                    l(e),
                        f(e),
                    t == null || t(e)
                }
                , {
                    once: !0
                })
    }
    const u = new WeakMap;
    function d(e, t) {
        if (e.dataset.sizes !== "auto")
            return;
        const r = y(e);
        if (r && (e.sizes = `${r}px`),
        _(e) && (t != null && t.processSourceElements))
            for (const n of [...e.parentElement.getElementsByTagName("source")])
                d(n, {
                    processSourceElements: !0
                });
        if (t != null && t.updateOnResize) {
            if (!u.has(e)) {
                const n = N( () => d(e), 500)
                    , c = new ResizeObserver(n);
                u.set(e, c),
                    c.observe(e)
            }
            return () => {
                const n = u.get(e);
                n && (n.disconnect(),
                    u.delete(e))
            }
        }
    }
    function f(e) {
        e.dataset.src && (e.src = e.dataset.src,
            e.removeAttribute("data-src"))
    }
    function l(e) {
        e.dataset.srcset && (e.srcset = e.dataset.srcset,
            e.removeAttribute("data-srcset"))
    }
    function p(e) {
        const t = e.parentElement;
        (t == null ? void 0 : t.tagName.toLowerCase()) === "picture" && ([...t.querySelectorAll("source[data-srcset]")].forEach(l),
            [...t.querySelectorAll("source[data-src]")].forEach(f))
    }
    function y(e) {
        var t, r;
        return e instanceof HTMLSourceElement ? (r = (t = e.parentElement) == null ? void 0 : t.getElementsByTagName("img")[0]) == null ? void 0 : r.offsetWidth : e.offsetWidth
    }
    function _(e) {
        var t;
        return ((t = e.parentElement) == null ? void 0 : t.tagName.toLowerCase()) === "picture"
    }
    const g = Object.freeze({
        autoSizes: w,
        lazyLoad: z,
        loadImage: o
    });
    return (b = document.currentScript) != null && b.hasAttribute("init") && z(),
        i.autoSizes = w,
        i.default = g,
        i.lazyLoad = z,
        i.loadImage = o,
        Object.defineProperties(i, {
            __esModule: {
                value: !0
            },
            [Symbol.toStringTag]: {
                value: "Module"
            }
        }),
        i
}({});
